TO_REAL block
Short summary
Name |
|
→POU type |
|
Category |
Standard (safe), Convert, block with internal error diagnostic |
Conform to →IEC-standard |
currently restricted and implementer-specific realization; see "Functionality" and more possible than defined in IEC-standard; see "Explicit conversion according to IEC-standard" |
Graphical interface |
|
Available since |
version 1.0.0 (for Neuron Power Engineer) – initial variant version 1.90.0 (for Neuron Power Engineer) – enhancement: version 3.2.0 (for library version 3.8.0 (for library |
Functionality
The blocks serves for explicitly converting the value connected to input IN
into a value of data type REAL
.
If the connected value is within the range of values overlapping for the data type of the input and for the result value REAL
, the blocks returns this value.
Deviation from IEC-standard The IEC-standard defines that the conversion for the data types as defined by the IEC-standard is done as a binary transfer. However, this block deviates from the IEC-standard. The values of the data type
|
Implementer-specific realization The IEC-standard defines that it is an error when the connected value is not within the range of values overlapping for the data type of the input and for the result value as well as that the behavior in the case of such an error is implementer specific. The general behavior of the conversion blocks inNeuron Power Engineer is as follows: The non-overlapping value range is not considered to be an error. Moreover, the following is valid: If the connected value is of the data type |
Observe as well:
-
If a value with more than 6 digits is converted, the result might be inexact. The reason is the number of significant digits of
REAL
(details: see "Supported data types (in ST)" the note 3 and the note 4 after the table). -
If a connected
LREAL
value is too large for the maximum or minimum value ofREAL
, the block returns+Infinity
or-Infinity
respectively. In this case, the outputENO
is set to valueTRUE
. -
If a value of data type
STRING
is connected to the input and this value is a valid real literal (see the following table for examples), the value is converted accordingly. In this case, the outputENO
is set to valueTRUE
.
In case of other values, the block returns the value0.0
. In this case, the outputENO
is set to valueFALSE
. Special case: If the connected value starts with a valid real literal and other characters follow (egB. '3.14159_26'
,STRING#'1.5 E10'
,'-INFxxx'
), the block returns the starting value as it is supported (hence:3.14159
,1.5
,-INF
) and the outputENO
is set to valueFALSE
.Description
Examples for values of data type
STRING
that correspond to a valid real literalsReal literal
'0', '0.0', '0.4560', '3.1415926', '-123456789',
STRING#'0', STRING#'0.0', STRING#'0.4560', STRING#'3.1415926', STRING#'-123456789'
Real literal with exponent
'-1.34E-12', '-1.34e-12', '1.0E+6', '1.0e+6, 1E+6', '1.234E6', '1.234e6',STRING#'-1.34E-12', STRING#'-1.34e-12', STRING#'1.0E+6', STRING#'1.0e+6, STRING#1E+6', STRING#'1.234E6', STRING#'1.234e6',' 987e-3', ' +2.5E30',STRING#' 987e-3', STRING#' +2.5E30'
"Not a Number" or infinite
'Nan', 'INF', '-INF'
Typed real literals (specifying the type
REAL
orLREAL
) are invalid real literals.
Examples for values of data typeSTRING
that correspond to an invalid real literal:'REAL#0.0'
or'LREAL#0.0'
-
If a value of data type
CHAR
is connected to the input and this value is a valid real literal (e.g.'0'
,CHAR#'9'
), the value is converted accordingly (hence:0.0
,9.0
). In this case, the outputENO
is set to valueTRUE
.
In case of other values (e.g.'+'
,CHAR#A
) , the block returns the value0.0
. In this case, the outputENO
is set to valueFALSE
.
Explicit conversion according to IEC-standard
The IEC-standard defines an explicit conversion of the following data types to REAL
:
LREAL
, LINT
, DINT
, INT
, SINT
, ULINT
, UDINT
, UINT
, USINT
, DWORD
The IEC-standard (Edition 3.0) defines a binary transfer for all data types of the input. But contrary to this, the appropriate value is converted according to the IEC-standard (Edition 2.0) for the following data types of the input.
DWORD
Example 1: The DWORD
value 16#43BE4000
is converted to the REAL
value 1.136542E+9
. But the conversion according to Edition 3.0 would return the REAL
value 380.5
.
Example 2: The DWORD
value 123
is converted to the REAL
value 123.0
. But the conversion according to Edition 3.0 would return the REAL
value 172.3597E-45
.
Details on the Neuron Power Engineer behavior of the block can be found in the section "Functionality".
Inputs, return value
|
Identifier |
Description |
|
---|---|---|---|
Inputs: |
|
|
value to be converted |
Return value: |
– |
|
|
Input EN
and output ENO
are available when →calling the block. See "Execution control: EN, ENO" for information on input EN
and output ENO
.
See:
-
"Blocks for safe logic" whether this block is supported for developing safety-relevant applications.
-
"Highlighting safe logic in the FBD-editor" for the effects when using the block as a block for safe logic.
Internal error diagnostic for block
The block checks the value connected to the input. The output ENO
of the block is set to value FALSE
(or an equivalent) in the following cases:
-
A
STRING
value contains an invalid character. (The value returned by the block depends on the position of the invalid characters. See the description under "Functionality" above.) -
A
CHAR
value contains an invalid character. (Moreover for this case, the block returns the value0.0
.)
Example for usage within ST-editor
|
When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.